Skip to content

Conversation

@atakavci
Copy link
Collaborator

There is half baked weighted endpoint selection in current implementation. This PR introduces the proper health status check while improves the overall quality of the code.

  • Add HealthStatus Enum
    • New HealthStatus enum with states: UNKNOWN, HEALTHY, UNHEALTHY
    • Default status is HEALTHY for new databases
  • Simplify Configuration
    • Removed RedisDatabase.RedisDatabaseConfig inner class
    • RedisDatabase now accepts DatabaseConfig directly
  • Improve Failover Logic
    • Failover now filters by HealthStatus.HEALTHY instead of circuit breaker state
    • Avoid unnecessary exceptions with getNextHealthyDatabase

@atakavci atakavci self-assigned this Nov 19, 2025
@atakavci atakavci added the type: feature A new feature label Nov 19, 2025
@atakavci atakavci requested a review from Copilot November 19, 2025 08:43
Copilot finished reviewing on behalf of atakavci November 19, 2025 08:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a HealthStatus enum and refactors the failover logic to use health-based endpoint selection instead of directly checking circuit breaker states. The changes simplify the configuration by removing the RedisDatabaseConfig inner class and having RedisDatabase accept DatabaseConfig directly.

Key Changes:

  • Added HealthStatus enum with UNKNOWN, HEALTHY, and UNHEALTHY states
  • Refactored RedisDatabase to use DatabaseConfig directly instead of inner RedisDatabaseConfig class
  • Updated failover logic in StatefulRedisMultiDbConnectionImpl to filter by health status instead of circuit breaker state

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
HealthStatus.java New enum defining health states (UNKNOWN, HEALTHY, UNHEALTHY) for database endpoints
RedisDatabase.java Removed inner RedisDatabaseConfig class, added healthStatus field with getter, updated constructor to accept DatabaseConfig directly
StatefulRedisMultiDbConnectionImpl.java Renamed getHealthyDatabase to getNextHealthyDatabase, changed filtering from circuit breaker state to health status, improved error handling with orElse(null)
MultiDbClientImpl.java Simplified database creation by passing DatabaseConfig directly instead of wrapping in RedisDatabaseConfig

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@atakavci atakavci changed the title [automatic failover] Implement weighted endpoint selection [automatic-failover] Implement weighted endpoint selection Nov 19, 2025
@atakavci atakavci requested review from Copilot and ggivo November 24, 2025 11:29
Copilot finished reviewing on behalf of atakavci November 24, 2025 11:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@tishun tishun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have any general concerns beside the assumption this is a partial change and this is why the health state is not mutable at all (as far as I can tell)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

- rename predicate function
- add javadoc
Copy link
Contributor

@ggivo ggivo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@tishun tishun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +6 to +19
*
* This file contains contributions from third-party contributors
* licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For new files we can omit this part, only the first 3 lines are required

@atakavci atakavci merged commit 5f3060f into redis:feature/automatic-failover-1 Nov 26, 2025
12 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants